import React, { useState, useEffect } from "react";
// import {u}
// import { useNavigate} from "react-router-dom";
import { NavBar, Space, Toast } from "antd-mobile";
import { useNavigate, useParams } from "react-router-dom";
import { hospitalid } from "./sevice/HomeList";
import { Image } from "antd-mobile";
import style from "./css/Home.module.css";
import "./css/style.less";
import { Button } from "antd-mobile";
import { category, dict } from "./sevice/HomeList";
import { Cell, Tabs } from "react-vant";
export default function () {
  const navigate = useNavigate();
  const { loveId } = useParams(); //loveId为路由详情的参数
  let [list, setList] = useState(); //是对象
  let [dictlist, setDictlist] = useState([]);
  let [dictlist1, setDictlist1] = useState([]);
  useEffect(() => {
    (async () => {
      let detail = await hospitalid(loveId);

      // console.log(detail, "啦啦");
      setList(detail.data.data);
      let categorylist = await category({ type: 1 });
      // console.log(categorylist, "科室分类");
      setDictlist([...categorylist.data.rows]);
      console.log(categorylist.data.rows, "lalfl");

      let categorylist2 = await category({ type: 2 });
      setDictlist1([...categorylist2.data.rows]);
      // console.log(c);
      console.log(categorylist2.data.rows, "专家科室");
      // let a = await dict("/prod-api/api/hospital/category/list")
      // console.log(a,"字典查询");
    })();
  }, []);
  useEffect(() => {
    // console.log(list, "叽叽叽叽");
  }, [list]);
  let btn = () => {
    // console.log(99999);
    navigate("/house/patient");
    // console.log(999);
  };
  let btn1 = (id) => {
    console.log(id, "oooooooo");
    // 生成预约单
    
  };
  return (
    <div>
      <NavBar
        onBack={() => {
          navigate("/house");
        }}
      >
        医院详情{loveId}
      </NavBar>
      {/* <Image src={"/api" + list.imgUrl} /> */}
      <img
        style={{ height: "100%", width: "100%" }}
        src={"/api" + list?.imgUrl}
        alt="描述"
      />
      {/* 普通诊和专家诊 */}
      <Tabs defaultActive={1}>
        <Tabs.TabPane title={"专家诊"}>
          {/* <Cell></Cell> */}
          {/* <Cell title='单元格' value='内容' />
           */}
          {dictlist?.map((item) => {
            return (
              <Cell
                title={item?.categoryName}
                value={item.money}
                key={item.id}
                onClick={() => {
                  btn1(item.id);
                }}
              >
                {" "}
                <div>
                  {item.money}{" "}
                  <Button size="mini" type="danger">
                    立即预约&nbsp;&nbsp;&nbsp;
                  </Button>
                </div>
              </Cell>
            );
          })}
        </Tabs.TabPane>
        <Tabs.TabPane title="普通诊">
          {dictlist1?.map((item) => {
            return (
              <Cell
                title={item?.categoryName}
                value={item.money}
                key={item.id}
                onClick={() => {
                  btn1(item.id);
                }}
              >
                {item.money}{" "}
                <Button size="mini" type="danger">
                  立即预约&nbsp;&nbsp;&nbsp;
                </Button>
              </Cell>
            );
          })}
        </Tabs.TabPane>
      </Tabs>
      <Button
        block
        color="primary"
        size="large"
        className={style.menu}
        onClick={() => {
          btn();
        }}
      >
        预约挂号
      </Button>
    </div>
  );
}
